package com.example.testproj.vibrator;

import android.content.Context;
import android.os.Vibrator;

import com.example.testproj.base.MyApplication;

/**
 * @des:
 * @author: 芮勤
 * @date: 2019/6/14 11:09
 * @see {@link }
 */
public class VibratorUtils {
    private static VibratorUtils instance;
    private final Vibrator vibrator;


    public VibratorUtils() {
        vibrator = (Vibrator) MyApplication.getInstance().getSystemService(Context.VIBRATOR_SERVICE);
    }

    public static VibratorUtils getInstance() {
        if (instance == null) {
            synchronized (VibratorUtils.class) {
                if (instance == null) {
                    instance = new VibratorUtils();
                }
            }
        }
        return instance;
    }

    public  void vibrator(int runTime, int sleepTime) {
        vibrator.vibrate(runTime);
        try {
            Thread.sleep(sleepTime+runTime);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
